<template>
	<view style="padding: 30rpx;">
		<view class="group-item" v-for="(item,index) in list" :key="index">
			<view class="group-right">
				<view class="group-item-title">{{item.title}}</view>
				<view class="group-item-title1">{{item.create_time}}</view>
			</view>
			<view class="group-item-price">
				{{item.payable_tuition_fees}}
			</view>
		</view>
		<u-empty v-if="list.length == 0" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png" width="150px"
			height="150px" text="列表为空" textSize="18">
		</u-empty>
		<view style="padding-bottom: 100rpx;">
			<u-loadmore v-if="loading" status="loading" />
			<u-loadmore v-if="isLastPage" status="nomore" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				list: [],
				isLastPage: false,
				loading: false,
			}
		},
		onShow() {
			this.page = 1
			this.limit = 10
			this.list = []
			this.getFreezeLogs()
		},
		// 刷新 上拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.isLastPage = false
			this.list = []
			this.getFreezeLogs()
		},
		// 加载下一页 下拉加载
		onReachBottom() {
			if (this.list.length >= this.page * this.limit) {
				this.isLastPage = false;
				this.page += 1;
				this.getFreezeLogs();
			} else {
				this.isLastPage = true
			}
		},
		methods: {
			getFreezeLogs() {
				this.$api.post(global.apiUrls.getSchoolTuitionfee, {
					page: this.page,
				}).then(res => {
					let arr = []
					arr = res.data.data.data.map(item => {
						return {
							title: item.title,
							payable_tuition_fees: item.payable_tuition_fees,
							id: item.id,
							create_time: uni.$u.timeFormat(item.create_time, 'yyyy年mm月dd日')
						}
					})
					console.log(res.data.data.data)
					this.list = [...this.list, ...arr]
				}).finally(() => {
					// 停止当前页面下拉刷新
					uni.stopPullDownRefresh();
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.group-item-title1 {
		font-size: 13px;
		color: #000000;
	}

	.group-item-title {
		font-size: 15px;
		color: #000000;
		margin-bottom: 20rpx;
	}

	.group-item-price {
		font-size: 24px;
		color: #000000;
	}

	.group-item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		margin-bottom: 30rpx;
	}
</style>